#!/bin/bash

SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)  # 获取脚本所在目录
PROJECT_DIR="$SCRIPT_DIR/.."                              # 假设脚本在 software/script/ 中

# 确保构建目录存在
BUILD_DIR="$PROJECT_DIR/build"
if [ ! -d "$BUILD_DIR" ]; then
    mkdir -p "$BUILD_DIR"
# else
#     rm -rf "$BUILD_DIR"/*    # 如果目录存在，先清空
fi

# 进入构建目录并编译
cd "$BUILD_DIR"
echo "Now work at Dir: $(pwd)"
cmake "$PROJECT_DIR" && make -j$(nproc)
make -j16